package com.ssy.lingxi.order.model.constant;

import java.util.Arrays;

/**
 * 订单营销活动状态枚举
 * @author 万宁
 * @version 2.0.0
 * @date 2021-11-29
 */
public enum OrderPromotionStatusEnum {
    /**
     * 无营销活动，或不需要考虑营销活动的状态
     */
    NONE(0, "无营销活动"),

    /**
     * 待确认拼团（拼团订单初始状态) - 1
     */
    GROUPING(1, "待确认拼团"),

    /**
     * （已经向营销服务发送确认消息）拼团中 - 2
     */
    GROUP_WAITING_CONFIRM(2, "拼团中"),

    /**
     * 拼团失败 - 3
     */
    GROUP_FAILED(3, "拼团失败"),

    /**
     * 拼团成功 - 4
     */
    GROUP_SUCCESS(4, "拼团成功");

    OrderPromotionStatusEnum(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    private Integer code;
    private String name;

    public Integer getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public static String getNameByCode(Integer code) {
        return Arrays.stream(OrderPromotionStatusEnum.values()).filter(e -> e.getCode().equals(code)).map(OrderPromotionStatusEnum::getName).findFirst().orElse("未知");
    }
}
